package net.zjitc.service.impl;

import net.zjitc.dao.CategoryDao;
import net.zjitc.dao.CategorySecondDao;
import net.zjitc.dao.impl.CategoryDaoImpl;
import net.zjitc.dao.impl.CategorySecondDaoImpl;
import net.zjitc.pojo.Category;
import net.zjitc.pojo.CategorySecond;
import net.zjitc.service.CategoryService;

import java.util.List;

/**
 * Created by Administrator on 2017/11/22.
 */
public class CategoryServiceImpl implements CategoryService {

    CategoryDao categoryDao = new CategoryDaoImpl();
    CategorySecondDao csdao=new CategorySecondDaoImpl();
    public List<Category> findAll() {
        List<Category> list=categoryDao.findAll();
        for (Category c:list){
            List<CategorySecond > cslist=csdao.findByCid(c.getCid());
            c.setCategorySecondList(cslist);
        }
        return list;
    }

    public int insert(Category category) {
        return categoryDao.insert(category);
    }

    public Category findByCid(String cid) {
        return categoryDao.findByCid(cid);
    }

    public int update(Category category) {
        return categoryDao.update(category);
    }

    public int delete(String cid) {
        return categoryDao.delete(cid);
    }
}
